package com.tico.editor.editors.service.impl;

import com.tico.common.service.impl.AbstractService;
import com.tico.common.utils.BaseQuery;
import com.tico.common.utils.QueryResult;
import com.tico.editor.editors.domain.TaskScheduled;
import com.tico.editor.editors.mapper.TaskScheduledMapper;
import com.tico.editor.editors.service.TaskScheduledService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 */
@Service
public class TaskScheduledServiceImpl extends AbstractService<TaskScheduled>  implements TaskScheduledService {


   @Autowired
   TaskScheduledMapper taskScheduledMapper;

   @Override
   public TaskScheduled findById(Serializable id) {
     return taskScheduledMapper.findById(id);
   }

    @Override
    public int update(TaskScheduled obj){
        return taskScheduledMapper.update(obj);
    }
    @Override
    public int insertBatch(List<TaskScheduled> taskScheduleds) {
      return taskScheduledMapper.insertBatch(taskScheduleds);
    }

    @Override
    public int insert(TaskScheduled taskScheduled) {
      return taskScheduledMapper.insert(taskScheduled);
    }
    @Override
    public List<TaskScheduled> findByNamedParamList(Map<String,Object> param){
        return taskScheduledMapper.findByNamedParamList(param);
    }

    @Override
    public int delete(Serializable id) {
      return taskScheduledMapper.delete(id);
    }

    @Override
    public int remove(Serializable id) {
      return taskScheduledMapper.remove(id);
    }

    @Override
    public QueryResult<TaskScheduled> findPageInfo(BaseQuery baseQuery) {
        QueryResult<TaskScheduled> result = new QueryResult<TaskScheduled>();
        result.setQuery(baseQuery);
        Map
        <String, Object> params = result.getQuery().build();
        Integer amount = this.taskScheduledMapper.countPageInfo(params);
        result.setTotalRecord(amount);
        if (amount == 0) {
        return result;
        }
        List<TaskScheduled> list = taskScheduledMapper.findPageInfo(params);
        if (!CollectionUtils.isEmpty(list)) {
        result.setResultList(list);

        }
        return result;
    }
}
